import request from "@/utils/request";
import { TakeAddress } from "@/type/TakeType";
import { ResponseType } from "@/type/ResponseType";

enum Enum {
   fetchAddressAPI = "/address/list",
   fetchDefaultTakeIdAPI = "/address/defaultId",
   deleteTakeAPI = "/address/remove",
   settinngDefaultTakeAPI="/address/setDefault"
}

/**
 * 获取收货地址列表的接口
 * */
export const fetchAddressAPI = () => request.get<{ list: TakeAddress[] }, ResponseType<{ list: TakeAddress[] }>>(Enum.fetchAddressAPI);

/**
 * @description 获取默认收货地址id
 * */
export const fetchDefaultTakeIdAPI = () => request.get<{ defaultId: number }, ResponseType<{ defaultId: number }>>(Enum.fetchDefaultTakeIdAPI);

/**
 * @description 删除收货地址的接口
 * */
export const deleteTakeAPI = (addressId: number) => request.post<string[], ResponseType<string[]>>(Enum.deleteTakeAPI, { addressId });

/**
 * @description 设置默认地址的接口
 * */
export const settingDefaultTakeAPI=(addressId:number)=>request.post(Enum.settinngDefaultTakeAPI, { addressId });
